package com.ruoyi.forum.service.impl;

import java.util.HashMap;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.forum.mapper.ForumReviewUpvoteMapper;
import com.ruoyi.forum.domain.ForumReviewUpvote;
import com.ruoyi.forum.service.IForumReviewUpvoteService;

/**
 * 评论-点赞Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-02-13
 */
@Service
public class ForumReviewUpvoteServiceImpl implements IForumReviewUpvoteService
{
    @Autowired
    private ForumReviewUpvoteMapper forumReviewUpvoteMapper;

    /**
     * 查询评论-点赞
     * 
     * @param id 评论-点赞主键
     * @return 评论-点赞
     */
    @Override
    public ForumReviewUpvote selectForumReviewUpvoteById(Long id)
    {
        return forumReviewUpvoteMapper.selectForumReviewUpvoteById(id);
    }

    /**
     * 查询评论-点赞列表
     * 
     * @param forumReviewUpvote 评论-点赞
     * @return 评论-点赞
     */
    @Override
    public List<ForumReviewUpvote> selectForumReviewUpvoteList(ForumReviewUpvote forumReviewUpvote)
    {
        return forumReviewUpvoteMapper.selectForumReviewUpvoteList(forumReviewUpvote);
    }

    /**
     * 新增评论-点赞
     * 
     * @param forumReviewUpvote 评论-点赞
     * @return 结果
     */
    @Override
    public int insertForumReviewUpvote(ForumReviewUpvote forumReviewUpvote)
    {
        forumReviewUpvote.setCreateTime(DateUtils.getNowDate());
        return forumReviewUpvoteMapper.insertForumReviewUpvote(forumReviewUpvote);
    }

    /**
     * 获取评论列表-根据用户id和帖子id
     *
     * @param userId 用户Id
     * @param postId 帖子Id
     * @return 结果
     */
    @Override
    public Long[] getLikeListForUserPost(Long userId, Long postId) {
        HashMap<String, Long> stringLongHashMap = new HashMap<>();
        stringLongHashMap.put("userId", userId);
        stringLongHashMap.put("postId", postId);
        Long[] likeListForUserPost = forumReviewUpvoteMapper.getLikeListForUserPost(stringLongHashMap);
        return likeListForUserPost;
    }

    /**
     * 修改评论-点赞
     * 
     * @param forumReviewUpvote 评论-点赞
     * @return 结果
     */
    @Override
    public int updateForumReviewUpvote(ForumReviewUpvote forumReviewUpvote)
    {
        return forumReviewUpvoteMapper.updateForumReviewUpvote(forumReviewUpvote);
    }

    /**
     * 批量删除评论-点赞
     * 
     * @param ids 需要删除的评论-点赞主键
     * @return 结果
     */
    @Override
    public int deleteForumReviewUpvoteByIds(Long[] ids)
    {
        return forumReviewUpvoteMapper.deleteForumReviewUpvoteByIds(ids);
    }

    /**
     * 删除评论-点赞信息
     * 
     * @param id 评论-点赞主键
     * @return 结果
     */
    @Override
    public int deleteForumReviewUpvoteById(Long id)
    {
        return forumReviewUpvoteMapper.deleteForumReviewUpvoteById(id);
    }
}
